<template>
    <svg :style="{ width, height }" class="svg-icon">
        <use :xlink:href="symbolId" :fill="color" />
    </svg>
</template>

<script setup>
import { computed, defineProps } from "vue"
const props = defineProps({
    prefix: {
        type: String,
        default: 'icon'
    },
    name: {
        type: String,
        required: true
    },
    width: {
        type: String,
        default: "24px"
    },
    height: {
        type: String,
        default: "18px"
    },
    color: {
        type: String,
        default: '#fff'
    }
})
// svg icon引入的格式
const symbolId = computed(() => {
    return `#${props.prefix}-${props.name}`
})
</script>

<style lang="css" scoped>
.svg-icon {
    margin-right: 5px;
}
</style>